#include<stdio.h>
#include<stdbool.h>
#include<stdlib.h>





typedef struct {
	int* a;
	int front;
	int rear;
	int k;
} MyCircularQueue;


MyCircularQueue* myCircularQueueCreate(int k) {
	MyCircularQueue* ptr = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
	ptr->a = (MyCircularQueue*)malloc(sizeof(int) * (k + 1));
	ptr->front = ptr->rear = 0;
	ptr->k = k;
	return ptr;
}

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
	if (myCircularQueueIsFull(obj))
		return false;
	if (obj->rear == obj->k)
	{
		obj->a[obj->rear] = value;
		obj->rear = 0;
	}
	else
	{
		obj->a[obj->rear] = value;
		obj->rear++;
	}
	return true;
}

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
	if (myCircularQueueIsEmpty(obj))
		return false;
	if (obj->front == obj->k)
	{
		obj->front = 0;
	}
	else
	{
		obj->front++;
	}
	return true;
}

int myCircularQueueFront(MyCircularQueue* obj) {
	if (myCircularQueueIsEmpty(obj))
		return -1;
	return obj->a[obj->front];
}

int myCircularQueueRear(MyCircularQueue* obj) {
	if (myCircularQueueIsEmpty(obj))
		return -1;
	if (obj->rear == 0)
		return obj->a[obj->k];
	return obj->a[obj->rear - 1];
}

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
	return obj->front == obj->rear;
}

bool myCircularQueueIsFull(MyCircularQueue* obj) {
	return (obj->rear + 1) % (obj->k + 1) == obj->front;
}

void myCircularQueueFree(MyCircularQueue* obj) {
	free(obj->a);
	free(obj);
}



int main()
{

	return 0;
}